package com.dcy.quartz.dao;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dcy.common.base.dao.DcyBaseDao;
import com.dcy.common.model.PageModel;
import com.dcy.quartz.mapper.JobMapper;
import com.dcy.quartz.model.Job;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 定时任务调度表 服务实现类
 * </p>
 *
 * @author dcy
 * @since 2022-11-09
 */
@Service
public class JobDao extends DcyBaseDao<JobMapper, Job> {

    /**
     * 获取表格数据
     *
     * @param job
     * @param pageModel
     * @return
     */
    public IPage<Job> pageListByEntity(Job job, PageModel pageModel) {
        LambdaQueryWrapper<Job> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.like(StrUtil.isNotBlank(job.getJobName()), Job::getJobName, job.getJobName());
        queryWrapper.like(StrUtil.isNotBlank(job.getJobGroup()), Job::getJobGroup, job.getJobGroup());
        queryWrapper.eq(StrUtil.isNotBlank(job.getJobStatus()), Job::getJobStatus, job.getJobStatus());
        return pageList(pageModel, queryWrapper);
    }

}
